package com.heima.manager.config;

import javax.sql.DataSource;

import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MybatisConfig {

    @Autowired
    private DataSource dataSource;
	
	@Bean
	@ConditionalOnMissingBean
	public SqlSessionFactoryBean sqlSessionFactoryBean(){
		
		SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();		
		sqlSessionFactoryBean.setDataSource(dataSource);
		
		return sqlSessionFactoryBean;
	}
	
}
